﻿package com.singlenotion.display.buttons 
{
	import flash.events.Event;
	import flash.events.MouseEvent;
	import gs.TweenLite;
	
	public class ToggleButton extends GenericButton 
	{
		private var _toggle:Boolean = false;
		
		public function ToggleButton() 
		{
			
		}
		
		override protected function onReleaseListener($e:MouseEvent):void 
		{
			if (_toggle) {
				gotoAndStop("on");
			} else {
				gotoAndStop("off");
			}
			
			_toggle = !_toggle;
			
			dispatchEvent(new Event(ButtonEvents.ON_RELEASE, false, true));
		}
		
		override protected function onRollOverListener($e:MouseEvent):void
		{
			dispatchEvent(new Event(ButtonEvents.ON_ROLLOVER, false, true));
		}
		
		override protected function onRollOutListener($e:MouseEvent):void
		{
			dispatchEvent(new Event(ButtonEvents.ON_ROLLOUT, false, true));
		}
		
		public function get toggle():Boolean { return _toggle; }
		
	}
	
}